package com.mashang.stuManSystem.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
public class R<T> {
    @ApiModelProperty("状态码")
    private Integer code;
    @ApiModelProperty("操作信息")
    private String msg;
    @ApiModelProperty("结果")
    private T data;

    public static<T> R<T> success(T data){
        return new R<T>(200, "操作成功", data);
    }

    public static<T> R<T> error(){
        return new R<T>(500, "操作失败", null);
    }
    public static<T> R<T> to(boolean b) {
        return b ? success(null) : error();
    }
}
